GKE チュートリアル
from GKE
コンテナ化されたウェブ アプリケーションのデプロイ  |  Kubernetes Engine  |  Google Cloud
$ kubectl autoscale deployment hello-app --cpu-percent=80 --min=1 --max=5
Horizontal Pod Autoscaler | Kubernetes
これなかったらどうなるの
$ k describe horizontalpodautoscaler.autoscaling/hello-app
code:describe
Metrics: ( current / target )
resource cpu on pods (as a percentage of request): <unknown> / 80%
Min replicas: 1
Max replicas: 5
Deployment pods: 3 current / 0 desired
Conditions:
Type Status Reason Message
---- ------ ------ -------
AbleToScale True SucceededGetScale the HPA controller was able to get the target's current scale
ScalingActive False FailedGetResourceMetric the HPA was unable to compute the replica count: missing request for cpu
metric とれてないので減らないのかな、1 になってもおかしくないと思うけど
これやってるからだ $ kubectl scale deployment hello-app --replicas=3
スケーリングパラメータ等は deployment にある
とりあえず $ k get all して describe とか get -o yaml とかで詳細みていくといい
$ kubectl expose deployment hello-app --name=hello-app-service --type=LoadBalancer --port 80 --target-port 8080
--type=LoadBalancer
Service | Kubernetes
外部ロードバランサ - ネットワークの概要  |  Kubernetes Engine ドキュメント  |  Google Cloud
Cloud Load Balancing が生えてくる
AWS でいう NLB のほう
別: Ingress による HTTP(S) 負荷分散の設定  |  Kubernetes Engine  |  Google Cloud
GKE でホストされている HTTP(S) サービスを公開する場合は、負荷分散として HTTP(S) 負荷分散の利用をおすすめします。
はい、実際に使うのはこっち Ingress による HTTP(S) 負荷分散の設定
AWS でいう ALB のほう
Service
どういう type があるのか
pod を束ねるからネットワークとめちゃ関係するのは分かる、LoadBalancer 以外には?
→ Serviceの公開 (Serviceのタイプ) - Service | Kubernetes
LoadBalancer = クラウドプロバイダーのロードバランサー
kubectl で見てみる
service/kubernetes はクラスタ内ネットワーク全体の ClusterIP Service かな?
$ k get service hello-app-service -o yaml とかすると LoadBalancer の YAML が見える
$ k describe service hello-app-service
まあ雰囲気しかわからん
Redis と PHP を使用したゲストブックの作成  |  Kubernetes Engine  |  Google Cloud
Redis たてるのか
実際には Memorystore 使うことになりそう、DB とかを乗せる気はない
永続化ボリュームとか指定してないけどいいのかな?
$ kubectl apply -f redis-leader-deployment.yaml
Schedule に失敗するとかはどこで分かるんだろ?
ワークロード的にムリっすとか
この deployment の selector は node を絞り込む selector じゃないのか
code:redis-leader-deployment.yaml
selector:
matchLabels:
app: redis
$ k get pod --show-labels
で既についてる
template を pod として作ってそれを select する deployment ってことか
Deploymentの作成 - Deployment | Kubernetes
$ kubectl logs deployment/redis-leader
$ kubectl apply -f redis-leader-service.yaml
$ kubectl apply -f redis-follower-deployment.yaml
leader/follower っていうの初めて聞く
image: gcr.io/google_samples/gb-redis-follower:v2
ここに replication 設定やら入ってるんかな
Dockerfile 見た
redis-server --replicaof ${REDIS_LEADER_SERVICE_HOST} 6379
$ kubectl apply -f redis-follower-service.yaml
#GKE #k8s #GoogleCloud